/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DAO;

import DAO.Iter.DeThiDAO;
import TableModel.Dethi;
import java.util.ArrayList;
import java.util.List;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;


/**
 *
 * @author vt
 */
public class DeThiDAOImpl extends HibernateDaoSupport implements DeThiDAO{
   private List<Dethi> list = new ArrayList<Dethi>();

    public List<Dethi> getList() {
        return list;
    }
    public void setList(List<Dethi> list) {
        this.list = list;
    }
    @Override
    public List<Dethi> findAllDeThi() {
        return  this.getHibernateTemplate().find("from Dethi dethi");
    }

    @Override
    public Dethi findDeThi(String id) {
       List list1 = this.getHibernateTemplate().find("from Dethi dethi where dethi.made = ?", id);
		if(list1.isEmpty()){
			return null;
		}
		return (Dethi) list1.get(0);
    }

    @Override
    public void update(Dethi id) {
        this.getHibernateTemplate().update(id);
    }

    @Override
    public long add(Dethi id) {
        long  a = (Long)this.getHibernateTemplate().save(id);
        this.getHibernateTemplate().flush();
         return a;
    }

    @Override
    public void delete(Dethi id) {
        this.getHibernateTemplate().delete(id);
    }

   
}
